package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.stereotype.Controller;

import com.zr.model.Cuser;
import com.zr.service.ShowGuoFanPriceService;

import net.sf.json.JSONObject;
@Controller
public class ShowGuoFanPriceAction implements ServletResponseAware,SessionAware{
	private Map<String, Object> session;
	private HttpServletResponse resp;
	private int page;
	private int rows;
	
	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}

	@Override
	public void setSession(Map<String, Object> arg0) {
		// TODO Auto-generated method stub
		this.session=arg0;
	}

	@Override
	public void setServletResponse(HttpServletResponse arg0) {
		// TODO Auto-generated method stub
		this.resp=arg0;
	}
	@Resource
	private ShowGuoFanPriceService shgufaprse;
	
	public void showGuoFanPrice(){
		resp.setCharacterEncoding("utf8");
		try {
			PrintWriter pw=resp.getWriter();
			Cuser cu=(Cuser) session.get("cuser");
			int uid=cu.getUid();
			JSONObject jo=shgufaprse.getFanPrice(page, rows, uid);
			pw.write(jo.toString());
			pw.flush();
			pw.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
